#ifndef FILESYS_CACHE_H
#define FILESYS_CACHE_H

#include "devices/disk.h"
#include "stdbool.h"
#include "stdint.h"
#include "threads/synch.h"

#define BUF_SIZE 64

struct cache {
	int sector_idx;
	uint8_t buffer[DISK_SECTOR_SIZE];

	bool dirtyBit;
	bool accessBit;
	bool allocateBit;

	struct lock cache_lock;
};

void cache_init(void);
int cache_finder(int sector_idx, bool want_lock);
void cache_read(int sector_idx, int offset, int read_byte, void *bounce);
void cache_write(int sectore_idx, int offset, int read_byte, void *bounce);
int find_empty_slot(void);
int evict_cache_slot(void);
void flush_cache_blocks(void);
void cache_flush_thread(void *);
void read_ahead_thread(void *);

#endif
